from typing import Dict, Type
from .base_recognizer import BaseCaptchaRecognizer
from .tesseract_recognizer import TesseractRecognizer
from .tensorflow_recognizer import TensorflowRecognizer

class RecognizerFactory:
    """验证码识别器工厂类"""
    
    _recognizers: Dict[str, Type[BaseCaptchaRecognizer]] = {
        'tesseract': TesseractRecognizer,
        'tensorflow': TensorflowRecognizer
    }
    
    @classmethod
    def create(cls, recognizer_type: str, **kwargs) -> BaseCaptchaRecognizer:
        """
        创建验证码识别器实例
        Args:
            recognizer_type: 识别器类型 ('tesseract' 或 'tensorflow')
            **kwargs: 传递给识别器的参数
        Returns:
            BaseCaptchaRecognizer: 识别器实例
        """
        if recognizer_type not in cls._recognizers:
            raise ValueError(f"不支持的识别器类型: {recognizer_type}")
            
        recognizer_class = cls._recognizers[recognizer_type]
        return recognizer_class(**kwargs) 